<script setup lang="ts">
import {useRouter} from "vue-router";
import {ref} from "vue";
import MyAxios from "@/plugins/myAxios.ts";
const router = useRouter();
const uId = ref<String>('');


const onSubmit = async () => {
  const res = await MyAxios.post("/uc", {
    uid: uId.value,
      }
  )
  // @ts-ignore
  if (res?.code === 200 && res.data) {
    router.push({
      path: '/search',
      replace: true,
    });
  } else {
  }
};
</script>

<template>
  <div class="logo">
    <img src="../../public/logo2.png" alt="校卡帮">
  </div>

  <van-form @submit="onSubmit" STYLE="padding-top:50px">
    <van-cell-group inset>
      <van-field
          v-model="uId as string"
          name="uId"
          label="学号"
          placeholder="学号"
          :rules=" [{ required: true, message: '请填写学号' },
    { pattern:  /^\d{10}$/, message: '请输入正确的学号' }]"
      />
    </van-cell-group>
    <div style="margin: 20px;">
      <van-button color="#FFC000" plain round block native-type="submit">
        一键登录
      </van-button>
    </div>
  </van-form>
  <div class="footer">
    <p>学号仅用于联系失主/拾卡者</p>
  </div>

</template>

<style scoped>
.logo {
  text-align: center;
  margin-top: 100px;
}

.logo img {
  width: 200px;
}
.footer {
  text-align: center;
  color: #C2C2C2; /* 文字颜色 */
  font-size: 14px;
}
</style>